//
//  ProductCell.m
//  FactorySale
//
//  Created by 胡小康 on 2020/4/21.
//  Copyright © 2020 主事丫环. All rights reserved.
//

#import "ProductCell.h"
#import "SYBigImage.h"
@interface ProductCell()
@property (weak, nonatomic) IBOutlet UILabel *typeLabel;// 种类
@property (weak, nonatomic) IBOutlet UILabel *contractPriceLabel;// 合同价
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;// 售价
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet UILabel *postLabel;
@property (weak, nonatomic) IBOutlet UILabel *notPostLabel;

@end
@implementation ProductCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
+ (instancetype)cellWithTableView:(UITableView *)tableView {
    
    static NSString *ID = @"ProductCell";
    
    ProductCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        
        cell = [NSBundle.mainBundle loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil].firstObject;
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
- (void)assignment:(CooperationPriductListModel *)model withUnit:(NSString *)unit {
    
    __weak typeof(self) _weakSelf = self;
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:model.attributeLogo] placeholderImage:imgname(GOODS_PLACE_HOLDER) completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        if (image && cacheType == SDImageCacheTypeNone) {
            _weakSelf.iconImageView.alpha = 0;
            [UIView animateWithDuration:1.0 animations:^{
                _weakSelf.iconImageView.alpha = 1.0f;
            }];
        } else {
            _weakSelf.iconImageView.alpha = 1.0f;
        }
    }];
    SYBigImage * bigI = [[SYBigImage alloc]init];
    [self.iconImageView addGestureRecognizer:bigI];
    self.iconImageView.userInteractionEnabled = YES;
    
    self.typeLabel.text = [NSString stringWithFormat:@"%@",model.name];
    self.contractPriceLabel.text = [NSString stringWithFormat:@"合同价：%.2f元/%@",model.contractPrice,unit];
    self.priceLabel.text = [NSString stringWithFormat:@"售价：¥%.2f元/%@",model.salePrice,unit];
//    if ([model.isPost isEqualToString:@"0"]) {
//        self.postLabel.hidden = YES;
//        self.notPostLabel.hidden = NO;
//    } else {
//        self.postLabel.hidden = NO;
//        self.notPostLabel.hidden = YES;
//    }
}
//- (void)setModel:(CooperationPriductListModel *)model {
//
//    self.typeLabel.text = [NSString stringWithFormat:@"%@",model.name];
//    self.contractPriceLabel.text = [NSString stringWithFormat:@"%.2f",model.contractPrice];
//    self.priceLabel.text = [NSString stringWithFormat:@"%.2f",model.salePrice];
//}
- (IBAction)changePriceClick {
//    _productCellBlock ? _productCellBlock() : nil;
    if ([self.delegate respondsToSelector:@selector(productCellChangePriceClick:)]) {
        [self.delegate productCellChangePriceClick:self.indexPath];
    }
    
}


@end
